<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>对象展开</title>
  </head>
  <body>
    <script>
      /*
      reset参数和扩展运算符在ES6中针对于数组，在ES9 中为对象提供了像数组一样的reset参数和扩展运算符
       */
      // 对象解构,使用reset参数
      function connecct({ host, port, ...user }) {
        console.log(host, port);
        console.log(user);
      }
      connecct({
        host: "127.0.0.1",
        port: 80,
        username: "root",
        password: "123456",
      });

      // 扩展运算符
      const one = {
        name: "张三",
        age: 18,
      };
      // 使用扩展运算符
      // ...one => name:"张三",age:"18"
      const two = {
        sex: "男",
        address: "北京",
      };
      const three = {
        phone: "13888888888",
        asy() {
          console.log("您好呀");
        },
      };

      // 使用扩展运算符合并对象
      const user = { ...one, ...two, ...three };
      console.log(user);
    </script>
  </body>
</html>
